<?php

class Jira_SoapClientAbstract extends SoapClient {
	protected function _objectArrayReturn($result,$classname){
		if(class_exists($classname)){
			foreach ($result as $index => $resObj){
				$result[$index] = $this->_objectReturn($resObj,$classname);
			}
		}
		return $result;
	}
	protected function _objectReturn($resultObject,$classname){
		if(class_exists($classname) && is_object($resultObject)){
			$returnObject = new $classname;
			foreach ($resultObject as $key => $value){
				$paramType = @$this->_bigTypeMap[$classname][$key];
				switch ($paramType) {
					case "dateTime":
						$value = str_replace(array("T","Z")," ",$value);
						$value = strtotime($value);
						$returnObject->$key = $value;
						break;

					default:
						if( str_start($paramType,$this->_namespace) && class_exists($paramType)){
							$returnObject->$key = $this->_objectReturn($value,$paramType);
						} elseif(key_exists($paramType,$this->_arrayOfObjects)) {
							$returnObject->$key = $this->_objectArrayReturn($value,$this->_arrayOfObjects[$paramType]);
						} else {
							$returnObject->$key = $value;
						}
						break;
				}
			}
			return $returnObject;
		} else {
			return $resultObject;
		}
	}
	protected function _putObject($putObject,$classname){
		if(is_a($putObject,$classname)){
			foreach ($putObject as $key => $value){
				$paramType = @$this->_bigTypeMap[$classname][$key];
				switch ($paramType) {
					case "dateTime":
						$putObject->$key = date("c",$value)."Z";
						break;

					default:
						/*
						if( str_start($paramType,$this->_namespace) && class_exists($paramType)){
							$returnObject->$key = $this->_objectReturn($value,$paramType);
						} elseif(key_exists($paramType,$this->_arrayOfObjects)) {
							$returnObject->$key = $this->_objectArrayReturn($value,$this->_arrayOfObjects[$paramType]);
						} else {
							$returnObject->$key = $value;
						}*/
						$putObject->$key = $value;
						break;
				}
			}
			return $putObject;
		} else {
			return $putObject;
		}
	}
}